<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2021/12/16
 * Time: 16:22
 */

/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2021/12/16
 * Time: 14:19
 */

include_once '../tools/DbTools.php';
session_start();

include_once '../common/common.php';
$isLogin = getLoginStatus();
if(!$isLogin){
    echo '尚未登入，<a href="../user/loginUi.php">请先登入</a>';die;
}
$money = $_POST['money'];
if(empty($money) || $money<0){
    echo '取款金额有误，<a href="transfer.php">重新转款</a>';die;
}
$id=$_POST['ID'];
if(empty($id)){
    echo '卡号不能为空，<a href="transfer.php">请输入卡号</a>';die;
}
$token = $_COOKIE['Token'];
$userInfo = $_SESSION[$token];
//本卡号CardId;
DbTools::init();
$b_CardId=$userInfo['CardId'];

//转账卡号CardId;
$z_CardId= getByCardId($id);
//
$result =changeMoney(2,$b_CardId,$money);

$result1 = changeMoney(1,$z_CardId,$money);

//
$sum=tran($b_CardId,$z_CardId,$money);
if($sum['status']){
    echo '转账成功<a href="transfer.php">继续转账</a>';
}else{
    echo '转账有误： '.$sum['message'];
}
DbTools::close();


